package Work03_Set;

import java.util.Comparator;
import java.util.Iterator;
import java.util.TreeSet;

public class SetTest {
    public static void main(String[] args) {
        TreeSet<String> treeSet=new TreeSet<>(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return 1;
            }
        });
        treeSet.add("刘备");treeSet.add("关羽");treeSet.add("张飞");treeSet.add("刘备");treeSet.add("张飞");
        System.out.println(treeSet.size());
        Iterator<String> iterator = treeSet.iterator();
        while (iterator.hasNext()) {
            String next =  iterator.next();
            System.out.println(next);
        }
        System.out.println("----------------------------------------------------------");
        for (String s : treeSet) {
            System.out.println(s);
        }
    }
}
